import { debounce } from "components/common/utils";
import BackTop from "components/content/backTop/BackTop";

// 监听每一个item项的加载情况
export const itemListenerMixin = {
  data() {
    return {
      itemImgListener: null,
      refresh: null
    }
  },
  mounted() {
    this.refresh = debounce(this.$refs.scroll.refresh, 100)
    this.itemImgListener = () => {
      this.refresh()
    }
    this.$bus.$on('itemImgLoad', this.itemImgListener)
    // console.log('我是混入导入');
  }
}
// 返回顶部混入
export const backTopMixin = {
  data() {
    return {
      isShowBackTop: false,
    }
  },
  components: {
    BackTop
  },
  methods: {
    backClick() {
      // 直接调用scroll里面封装好的scrollTo方法
      this.$refs.scroll.scrollTo(0, 0, 1000);
    },
  }
}
